package com.itsxb.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import com.itsxb.pojo.domain.DriverAuthMaterial;
import com.itsxb.pojo.dto.WechatRegisterDto;
import com.itsxb.pojo.vo.DriverLocation2GeoVo;
import com.itsxb.result.R;
import com.itsxb.service.IDriverAuthMaterialService;
import com.itsxb.service.IDriverService;
import com.itsxb.service.IDriverSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@Tag(name = "注册表",description = "注册表")
//@SpringBootApplication注解 为什么不报错
@RequestMapping("/app/driver")
public class DriverRegistryController {
    @Autowired
    private IDriverService driverService;
    @Autowired
    private IDriverAuthMaterialService driverAuthMaterialService;
    @Autowired
    private IDriverSettingService driverSettingService;
    @PostMapping("/driverLocation2Geo")
    @Operation( summary= "保存司机坐标到Geo信息",description = "保存司机坐标到Geo信息接口")
    @Parameter(name = "",description = "保存司机坐标到Geo信息",required = true)
    public R driverLocation2Geo(@RequestBody @Valid DriverLocation2GeoVo driverLocation2GeoVo){
        driverSettingService.driverLocation2Geo(driverLocation2GeoVo);
        return R.success();
    }

    @PostMapping("/online")
    @Operation( summary= "保存司机上线信息",description = "保存司机上线信息接口")
    @Parameter(name = "",description = "保存司机上线信息",required = true)
    public R online(){
        driverSettingService.online();
        return R.success();
    }

    @PostMapping("/offline")
    @Operation( summary= "保存司机下线信息",description = "保存司机下线信息接口")
    @Parameter(name = "",description = "保存司机下线信息",required = true)
    public R offline(){
        driverSettingService.offline();
        return R.success();
    }

    @PostMapping("/getWorkbenchInfo")
    @Operation( summary= "查询工作台需要的信息",description = "查询工作台需要的信息接口")
    @Parameter(name = "",description = "查询工作台需要的信息",required = true)
    public R getWorkbenchInfo(){

        return R.success(driverAuthMaterialService.getWorkbenchInfo());
    }
    @PostMapping("/getYourselfAuthMaterial")
    @Operation( summary= "查询自己的司机材料认证信息",description = "查询自己的司机材料认证信息接口")
    @Parameter(name = "",description = "查询自己的司机材料认证信息",required = true)
    public R getYourselfAuthMaterial(){

        return R.success(driverAuthMaterialService.getYourselfAuthMaterial());
    }


    @PostMapping("/realNameAuth")
    @Operation( summary= "实名认证",description = "实名认证接口")
    @Parameter(name = "driverAuthMaterial",description = "实名认证",required = true)
//    @SaIgnore
    //这里进行了Serivce层中的参数校验JSR303
    public R realNameAuth(@RequestBody @Valid DriverAuthMaterial driverAuthMaterial){
        driverService.realNameAuth(driverAuthMaterial);
        return R.success();
    }

    @PostMapping("/wechatRegister")
    @Operation( summary= "注册鉴权",description = "注册鉴权保存接口")
    @Parameter(name = "registry",description = "注册鉴权",required = true)
    @SaIgnore
    public R wechatRegister(@RequestBody @Valid WechatRegisterDto wechatRegisterDto){
        driverService.wechatRegister(wechatRegisterDto);
        return R.success();
    }
}
